﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Empty.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="changePasswordContent" ContentPlaceHolderID="MainContent" runat="server">

    <script type="text/javascript">

        $(document).ready(function() {
            $("#currentPassword").vRequire({
                errorText: "请填写旧密码。",
                group:"changePassword"
            });
            $("#newPassword").vRequire({
                errorText: "请填写新密码。",
                group:"changePassword"
            }).vLength({
                errorText: "密码至少需要<%=Membership.MinRequiredPasswordLength %>位。",
                min:<%=Membership.MinRequiredPasswordLength%>
            });
            $("#confirmPassword").vCompare({
                errorText: "两次密码不一致。",
                target: $("#newPassword"),
                empty: true,
                group:"changePassword"
            });           
            
            $("#ChangePasswordButton").click(changePassword);
            shortcut.add("enter",changePassword);

        });
        
        function changePassword()
        {
          if($.easyValidate('check',"changePassword")){
            var data={
                currentPassword:$("#currentPassword").val(),
                newPassword:$("#newPassword").val(),               
                confirmPassword:$("#confirmPassword").val()
            };
            
            $.post('<%=Url.Action("ChangePassword")%>',data,function(result){                        
                alert(result.Message);
            });
          }        
        }
        
    </script>

    <p>
        新的密码至少需要
        <%=Html.Encode(ViewData["PasswordLength"])%>
        位长度
    </p>
    <div>
        <fieldset class="cssform">
            <legend>帐户信息</legend>
            <p>
                <label for="currentPassword">
                    旧密码:</label>
                <%= Html.Password("currentPassword") %>
                <%= Html.ValidationMessage("currentPassword") %>
            </p>
            <p>
                <label for="newPassword">
                    新密码:</label>
                <%= Html.Password("newPassword") %>
                <%= Html.ValidationMessage("newPassword") %>
            </p>
            <p>
                <label for="confirmPassword">
                    确认新密码:</label>
                <%= Html.Password("confirmPassword") %>
                <%= Html.ValidationMessage("confirmPassword") %>
            </p>
            <p>
                <input id="ChangePasswordButton" type="button" value="确认" />
            </p>
        </fieldset>
    </div>
</asp:Content>
